package cn.itsource.service.impl;

import cn.itsource.domain.Permission;
import cn.itsource.dto.PermissionQuery;
import cn.itsource.mapper.PermissionMapper;
import cn.itsource.service.IPermissionService;
import cn.itsource.ymcc.result.PageList;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class IPermissionServiceImpl implements IPermissionService {
    @Autowired
    PermissionMapper permissionMapper;


    @Override
    public PageList<Permission> pagelist(PermissionQuery query) {
        RowBounds rowBounds = new RowBounds(query.getPage(), query.getRows());
        EntityWrapper<Permission> wrapper = new EntityWrapper<>();
        wrapper.like("name",query.getKeyword());
        List<Permission> permissions = permissionMapper.selectPage(rowBounds, wrapper);
        Integer integer = permissionMapper.selectCount(wrapper);

        return new PageList<>(integer.longValue(),permissions);
    }
}
